﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace Maticsoft.Web.monthSupplayPlan
{
    public partial class Add : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
                       
        }

        		protected void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(!PageValidate.IsDateTime(txtsupplyDate.Text))
			{
				strErr+="supplyDate格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtsupplyPlanId.Text))
			{
				strErr+="supplyPlanId格式错误！\\n";	
			}
			if(!PageValidate.IsDecimal(txtthisMonthCount.Text))
			{
				strErr+="thisMonthCount格式错误！\\n";	
			}
			if(this.txtgoodsQualityStatus.Text.Trim().Length==0)
			{
				strErr+="goodsQualityStatus不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtgoodsQualityStatusDate.Text))
			{
				strErr+="goodsQualityStatusDate格式错误！\\n";	
			}
			if(this.txtsendStatus.Text.Trim().Length==0)
			{
				strErr+="sendStatus不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtsendStatusDate.Text))
			{
				strErr+="sendStatusDate格式错误！\\n";	
			}
			if(!PageValidate.IsDateTime(txtlastArrivalDate.Text))
			{
				strErr+="lastArrivalDate格式错误！\\n";	
			}
			if(!PageValidate.IsDecimal(txtfristCheckedCount.Text))
			{
				strErr+="fristCheckedCount格式错误！\\n";	
			}
			if(!PageValidate.IsDateTime(txtlastCheckedDate.Text))
			{
				strErr+="lastCheckedDate格式错误！\\n";	
			}
			if(!PageValidate.IsDecimal(txtinstoreCount.Text))
			{
				strErr+="instoreCount格式错误！\\n";	
			}
			if(!PageValidate.IsDateTime(txtlastInstoreDate.Text))
			{
				strErr+="lastInstoreDate格式错误！\\n";	
			}
			if(this.txtresult.Text.Trim().Length==0)
			{
				strErr+="result不能为空！\\n";	
			}
			if(this.txtarrivalAddress.Text.Trim().Length==0)
			{
				strErr+="arrivalAddress不能为空！\\n";	
			}
			if(this.txtlinkman.Text.Trim().Length==0)
			{
				strErr+="linkman不能为空！\\n";	
			}
			if(this.txtcontactWay.Text.Trim().Length==0)
			{
				strErr+="contactWay不能为空！\\n";	
			}
			if(!PageValidate.IsNumber(txtuser_id.Text))
			{
				strErr+="user_id格式错误！\\n";	
			}
			if(this.txtstatus.Text.Trim().Length==0)
			{
				strErr+="status不能为空！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			DateTime supplyDate=DateTime.Parse(this.txtsupplyDate.Text);
			int supplyPlanId=int.Parse(this.txtsupplyPlanId.Text);
			decimal thisMonthCount=decimal.Parse(this.txtthisMonthCount.Text);
			string goodsQualityStatus=this.txtgoodsQualityStatus.Text;
			DateTime goodsQualityStatusDate=DateTime.Parse(this.txtgoodsQualityStatusDate.Text);
			string sendStatus=this.txtsendStatus.Text;
			DateTime sendStatusDate=DateTime.Parse(this.txtsendStatusDate.Text);
			DateTime lastArrivalDate=DateTime.Parse(this.txtlastArrivalDate.Text);
			decimal fristCheckedCount=decimal.Parse(this.txtfristCheckedCount.Text);
			DateTime lastCheckedDate=DateTime.Parse(this.txtlastCheckedDate.Text);
			decimal instoreCount=decimal.Parse(this.txtinstoreCount.Text);
			DateTime lastInstoreDate=DateTime.Parse(this.txtlastInstoreDate.Text);
			string result=this.txtresult.Text;
			string arrivalAddress=this.txtarrivalAddress.Text;
			string linkman=this.txtlinkman.Text;
			string contactWay=this.txtcontactWay.Text;
			int user_id=int.Parse(this.txtuser_id.Text);
			string status=this.txtstatus.Text;

			Maticsoft.Model.monthSupplayPlan model=new Maticsoft.Model.monthSupplayPlan();
			model.supplyDate=supplyDate;
			model.supplyPlanId=supplyPlanId;
			model.thisMonthCount=thisMonthCount;
			model.goodsQualityStatus=goodsQualityStatus;
			model.goodsQualityStatusDate=goodsQualityStatusDate;
			model.sendStatus=sendStatus;
			model.sendStatusDate=sendStatusDate;
			model.lastArrivalDate=lastArrivalDate;
			model.fristCheckedCount=fristCheckedCount;
			model.lastCheckedDate=lastCheckedDate;
			model.instoreCount=instoreCount;
			model.lastInstoreDate=lastInstoreDate;
			model.result=result;
			model.arrivalAddress=arrivalAddress;
			model.linkman=linkman;
			model.contactWay=contactWay;
			model.user_id=user_id;
			model.status=status;

			Maticsoft.BLL.monthSupplayPlan bll=new Maticsoft.BLL.monthSupplayPlan();
			bll.Add(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","Add.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
